************************************************************************************************************************************************
* Replication code for "Personal Proximity and Reactions to Terrorism", Comparative Political Studies
* Authors: Mattias Agerberg, University of Gothenburg, mattias.agerberg@gu.se - Jacob Sohlberg, University of Gothenburg, jacob.sohlberg@gu.se
************************************************************************************************************************************************

use "... CPS replication data.dta", clear 
cd "..."
local path "..."

// Packages: kmatch, xtile, coefplot, esttab


************************************************************************************************************************************************
****** ANALYSIS, MAIN MANUSCRIPT ******
************************************************************************************************************************************************

// FIGURE 2: Emotional response, descriptive
hist q19_1_w9, discrete xlabel(1 "Not at all" 2 " " 3 " " 4 " " 5 " " 6 " " 7 `" "To a very" "large extent" "') graphregion(margin(l+0 r+2 t+0 b+0)) plotregion(margin(l-6 r+0 t+0 b+0)) scheme(s2mono) ///
title("Feeling: anger", margin(medsmall)) xtitle(" ") ytitle("Density", margin(medsmall))  name(angerhist, replace)

hist q19_2_w9, discrete xlabel(1 "Not at all" 2 " " 3 " " 4 " " 5 " " 6 " " 7 `" "To a very" "large extent" "') graphregion(margin(l+0 r+2 t+0 b+0)) plotregion(margin(l-6 r+0 t+0 b+0)) scheme(s2mono) ///
title("Feeling: anxiety", margin(medsmall)) xtitle(" ") ytitle("Density", margin(medsmall))  name(anxietyhist, replace)

gr combine angerhist anxietyhist, col(2) scheme(s2mono) ycommon ysize(5) xsize(9) scale(1.1)
* graph export  "`path'emotional_response_hist.pdf", replace

************************************************************************************************************************************************

// FIGURE 3: General trends
reg natid_diff_w9 if wave8 == 1
est sto natid_diff_w9e
reg natid_diff_w10 if wave8 == 1
est sto natid_diff_w10e

reg govtrust_diff_w9 if wave8 == 1
est sto govtrust_diff_w9e
reg govtrust_diff_w10 if wave8 == 1
est sto govtrust_diff_w10e

reg parltrust_diff_w9 if wave8 == 1
est sto parltrust_diff_w9e
reg parltrust_diff_w10 if wave8 == 1
est sto parltrust_diff_w10e

reg security_diff_w9 if wave8 == 1
est sto security_diff_w9e
reg security_diff_w10 if wave8 == 1
est sto security_diff_w10e

reg muslimthreat_diff_w9 if wave8 == 1
est sto muslimthreat_diff_w9e
reg muslimthreat_diff_w10 if wave8 == 1
est sto muslimthreat_diff_w10e

reg fewerref_diff_w9 if wave8 == 1 
est sto fewerref_diff_w9e
reg fewerref_diff_w10 if wave8 == 1
est sto fewerref_diff_w10e

* Graph
set graphics on

coefplot (natid_diff_w9e, lc(black) mcolor(black) msize(small) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(small) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(small) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(small) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(small) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(small) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(small) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Difference between t1/t2 and t0", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+1 r+1 t+0 b+0)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4) swapnames 
* graph export  "`path'general_trends.pdf", replace

************************************************************************************************************************************************

// FIGURE 4: Emotional response, proximity
* Stockholm, matching dir
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg i.edu_resp leftrightw8 age 

* Affected proximity
kmatch em diraffected_sthlm $Cw82 (q16_w92 = diraffected_sthlm $Creg), att
est sto insthlme
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

reg q16_w92 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q16_w92 proximity_medhigh if diraffected_sthlm==1, robust
est sto medhighproxe
estadd local treated = obs

reg q16_w92 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q16_w92 proximity_high if diraffected_sthlm==1, robust
est sto highproxe
estadd local treated = obs

kmatch em diraffected_sthlm $Cw82 (q16_w102 = diraffected_sthlm $Creg), att
est sto insthlme10
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

reg q16_w102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q16_w102 proximity_medhigh if diraffected_sthlm==1, robust
est sto medhighproxe10
estadd local treated = obs

reg q16_w102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q16_w102 proximity_high if diraffected_sthlm==1, robust
est sto highproxe10
estadd local treated = obs

* Anger proximity
kmatch em diraffected_sthlm $Cw82 (anger_sthlm_01 = diraffected_sthlm $Creg), att
est sto insthlme2
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

reg anger_sthlm_01 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg anger_sthlm_01 proximity_medhigh if diraffected_sthlm==1, robust
est sto medhighproxe2
estadd local treated = obs

reg anger_sthlm_01 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg anger_sthlm_01 proximity_high if diraffected_sthlm==1, robust
est sto highproxe2
estadd local treated = obs

kmatch em diraffected_sthlm $Cw82 (anger_sthlm_01w10 = diraffected_sthlm $Creg), att
est sto insthlme102
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

reg anger_sthlm_01w10 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg anger_sthlm_01w10 proximity_medhigh if diraffected_sthlm==1, robust
est sto medhighproxe102
estadd local treated = obs

reg anger_sthlm_01w10 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg anger_sthlm_01w10 proximity_high if diraffected_sthlm==1, robust
est sto highproxe102
estadd local treated = obs

* Anxiety proximity
kmatch em diraffected_sthlm $Cw82 (anxiety_sthlm_01 = diraffected_sthlm $Creg), att
est sto insthlme3
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

reg anxiety_sthlm_01 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg anxiety_sthlm_01 proximity_medhigh if diraffected_sthlm==1, robust
est sto medhighproxe3
estadd local treated = obs

reg anxiety_sthlm_01 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg anxiety_sthlm_01 proximity_high if diraffected_sthlm==1, robust
est sto highproxe3
estadd local treated = obs

kmatch em diraffected_sthlm $Cw82 (anxiety_sthlm_01w10 = diraffected_sthlm $Creg), att
est sto insthlme103
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

reg anxiety_sthlm_01w10 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg anxiety_sthlm_01w10 proximity_medhigh if diraffected_sthlm==1, robust
est sto medhighproxe103
estadd local treated = obs

reg anxiety_sthlm_01w10 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg anxiety_sthlm_01w10 proximity_high if diraffected_sthlm==1, robust
est sto highproxe103
estadd local treated = obs

* Graph
set graphics off
coefplot (insthlme, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("In Sthlm, T1")) (insthlme10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("In Sthlm, T2")) /// 
(medhighproxe, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxe10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxe, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxe10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Subjectively affected by attack", margin(medsmall) size(medlarge)) drop(_cons) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(affected, replace)

coefplot (insthlme2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("In Sthlm, T1")) (insthlme102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("In Sthlm, T2")) /// 
(medhighproxe2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxe102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxe2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxe102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Feeling anger", margin(medsmall) size(medlarge)) drop(_cons) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(anger, replace)

coefplot (insthlme3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("In Sthlm, T1")) (insthlme103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("In Sthlm, T2")) /// 
(medhighproxe3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxe103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxe3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxe103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Feeling anxiety", margin(medsmall) size(medlarge)) drop(_cons) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(anxiety, replace)

set graphics on
gr combine affected anger anxiety, col(3) scheme(s2mono) ysize(5) xsize(13) scale(1.1) title("Effect of personal proximity") 
* graph export  "`path'combined_proximity4.pdf", replace

* TABLE 18 (online appendix), In stockholm, \footnotesize
esttab insthlme insthlme10 insthlme2 insthlme102 insthlme3 insthlme103, se scalars("adj Post-match adj." "treated Treated matched " "controls Controls used ") obslast ///
mti("Affected, T1" "Affected, T2" "Anger, T1" "Anger, T2" "Anxiety, T1" "Anxiety, T2") title("In central Stockholm: Matching estimates, emotional response") ///
tex compress b(a2) se(a2) width(16cm) ///
addn(Note: Standard errors in parentheses. Treatment: In central Stockholm during attack. /// 
Estimates based on coarsened exact matching. /// 
Matching variables include: education, foreign born, gender, age, SD-voter, /// 
government-voter, ideological placement on the left-right scale, large municipality inhabitant, and Stockholm inhabitant. /// 
See appendix for coarsening details. Post-matching regression adjustment (OLS) with ///  
education (categorical dummies), age, and left-right placement. \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes 

* TABLE 19 (online appendix), Med/high prox, \footnotesize
esttab medhighproxe medhighproxe10 medhighproxe2 medhighproxe102 medhighproxe3 medhighproxe103, se scalars("treated Treated ") obslast ///
mti("Affected, T1" "Affected, T2" "Anger, T1" "Anger, T2" "Anxiety, T1" "Anxiety, T2") title("Med/high proximity: OLS estimates with restricted sample, emotional response") ///
label ///
tex compress b(a2) se(a2) width(16.5cm) keep(proximity_medhigh _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates. Sample is restricted to respondents who were in central Stockholm at the time of the attack. Treatment: Med/high proximity to attack. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
 * TABLE 20 (online appendix), High prox, \footnotesize
esttab highproxe highproxe10 highproxe2 highproxe102 highproxe3 highproxe103, se scalars("treated Treated ") obslast ///
mti("Affected, T1" "Affected, T2" "Anger, T1" "Anger, T2" "Anxiety, T1" "Anxiety, T2") title("High proximity: OLS estimates with restricted sample, emotional response") ///
label ///
tex compress b(a2) se(a2) width(16cm) keep(proximity_high _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates. Sample is restricted to respondents who were in central Stockholm at the time of the attack. Treatment: Med/high proximity to attack. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes

************************************************************************************************************************************************

// FIGURE 5: Proximity, matching
* + Balance graphs for matching (presented in online appendix) 
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg i.edu_resp leftrightw8 age 
global Cbal edu_resp leftrightw8 age 

* Stockholm, matching dir, w9
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w92 = diraffected_sthlm s10_q85_w82 $Creg), att
est sto natid_diff_w9e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch cum $Cbal s10_q85_w82, scheme(s2mono)

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlm2 = diraffected_sthlm security_paris2 $Creg), att
est sto security_diff_w9e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch cum $Cbal security_paris2, scheme(s2mono)

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w92 = diraffected_sthlm q80_1_w82 $Creg), att
est sto govtrust_diff_w9e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch cum $Cbal q80_1_w82, scheme(s2mono)

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w92 = diraffected_sthlm q80_2_w82 $Creg), att
est sto parltrust_diff_w9e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch cum $Cbal q80_2_w82, scheme(s2mono)

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref92 = diraffected_sthlm fewercntrl_w92 $Creg), att
est sto fewerref_diff_w9e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch cum $Cbal fewercntrl_w92, scheme(s2mono)

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat92 = diraffected_sthlm muslimcntrl_w92 $Creg), att
est sto muslimthreat_diff_w9e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch cum $Cbal muslimcntrl_w92, scheme(s2mono)

* Stockholm, matching dir, w10
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w102 = diraffected_sthlm s10_q85_w82 $Creg), att
est sto natid_diff_w10e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlmw102 = diraffected_sthlm security_paris2 $Creg), att
est sto security_diff_w10e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w102 = diraffected_sthlm q80_1_w82 $Creg), att
est sto govtrust_diff_w10e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w102 = diraffected_sthlm q80_2_w82 $Creg), att
est sto parltrust_diff_w10e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref102 = diraffected_sthlm fewercntrl_w92 $Creg), att
est sto fewerref_diff_w10e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat102 = diraffected_sthlm muslimcntrl_w92 $Creg), att
est sto muslimthreat_diff_w10e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

* Graph
set graphics on

coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("In central Stockholm during attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4) swapnames name(insthlm, replace)
* graph export  "`path'combined_proximity1.pdf", replace

* TABLE 11 (online appendix), T1
esttab natid_diff_w9e govtrust_diff_w9e parltrust_diff_w9e security_diff_w9e muslimthreat_diff_w9e fewerref_diff_w9e, se scalars("adj Post-match adj." "treated Treated matched " "controls Controls used ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("In central Stockholm: Matching estimates, t1") ///
tex compress b(a2) se(a2) width(15.5cm) ///
addn(Note: Standard errors in parentheses. Outcomes measured at t1. Treatment: In central Stockholm during attack. /// 
Estimates based on coarsened exact matching. /// 
Matching variables include: education, foreign born, gender, age, SD-voter, /// 
government-voter, ideological placement on the left-right scale, past values of dependent variable, large municipality inhabitant, and Stockholm inhabitant. /// 
See appendix for coarsening details. Post-matching regression adjustment (OLS) with ///  
education (categorical dummies), age, left-right placement, and past values of dependent variable. \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes 

* TABLE 12 (online appendix), T2
esttab natid_diff_w10e govtrust_diff_w10e parltrust_diff_w10e security_diff_w10e muslimthreat_diff_w10e fewerref_diff_w10e, se scalars("adj Post-match adj." "treated Treated matched " "controls Controls used ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("In central Stockholm: Matching estimates, t2") ///
tex compress b(a2) se(a2) width(15.5cm) ///
addn(Note: Standard errors in parentheses. Outcomes measured at t2. Treatment: In central Stockholm during attack. /// 
Estimates based on coarsened exact matching. /// 
Matching variables include: education, foreign born, gender, age, SD-voter, /// 
government-voter, ideological placement on the left-right scale, past values of dependent variable, large municipality inhabitant, and Stockholm inhabitant. /// 
See appendix for coarsening details. Post-matching regression adjustment (OLS) with ///  
education (categorical dummies), age, left-right placement, and past values of dependent variable. \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes 

************************************************************************************************************************************************

// FIGURE 6: Reg, Sthlm medhigh/high proximity - between-group diff, no matching
* Stockholm, medhigh prox, T1
reg q28_w92 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q28_w92 proximity_medhigh if diraffected_sthlm==1, robust
est sto natid_diff_w9e
estadd local treated = obs

reg security_sthlm2 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg security_sthlm2 proximity_medhigh if diraffected_sthlm==1, robust
est sto security_diff_w9e
estadd local treated = obs

reg q24_1_w92 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q24_1_w92 proximity_medhigh if diraffected_sthlm==1, robust
est sto govtrust_diff_w9e
estadd local treated = obs

reg q24_2_w92 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q24_2_w92 proximity_medhigh if diraffected_sthlm==1, robust
est sto parltrust_diff_w9e
estadd local treated = obs

reg fewerref92 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg fewerref92 proximity_medhigh if diraffected_sthlm==1, robust
est sto fewerref_diff_w9e
estadd local treated = obs

reg muslimthreat92 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg muslimthreat92 proximity_medhigh if diraffected_sthlm==1, robust
est sto muslimthreat_diff_w9e
estadd local treated = obs

* Stockholm, medhigh prox, T2
reg q28_w102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q28_w102 proximity_medhigh if diraffected_sthlm==1, robust
est sto natid_diff_w10e
estadd local treated = obs

reg security_sthlmw102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg security_sthlmw102 proximity_medhigh if diraffected_sthlm==1, robust
est sto security_diff_w10e
estadd local treated = obs

reg q24_1_w102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q24_1_w102 proximity_medhigh if diraffected_sthlm==1, robust
est sto govtrust_diff_w10e
estadd local treated = obs

reg q24_2_w102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg q24_2_w102 proximity_medhigh if diraffected_sthlm==1, robust
est sto parltrust_diff_w10e
estadd local treated = obs

reg fewerref102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg fewerref102 proximity_medhigh if diraffected_sthlm==1, robust
est sto fewerref_diff_w10e
estadd local treated = obs

reg muslimthreat102 if diraffected_sthlm==1 & proximity_medhigh==1
scalar obs = e(N)
reg muslimthreat102 proximity_medhigh if diraffected_sthlm==1, robust
est sto muslimthreat_diff_w10e
estadd local treated = obs

* Stockholm, high prox
reg q28_w92 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q28_w92 proximity_high if diraffected_sthlm==1, robust
est sto natid_diff_w9e2
estadd local treated = obs

reg security_sthlm2 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg security_sthlm2 proximity_high if diraffected_sthlm==1, robust
est sto security_diff_w9e2
estadd local treated = obs

reg q24_1_w92 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q24_1_w92 proximity_high if diraffected_sthlm==1, robust
est sto govtrust_diff_w9e2
estadd local treated = obs

reg q24_2_w92 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q24_2_w92 proximity_high if diraffected_sthlm==1, robust
est sto parltrust_diff_w9e2
estadd local treated = obs

reg fewerref92 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg fewerref92 proximity_high if diraffected_sthlm==1, robust
est sto fewerref_diff_w9e2
estadd local treated = obs

reg muslimthreat92 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg muslimthreat92 proximity_high if diraffected_sthlm==1, robust
est sto muslimthreat_diff_w9e2
estadd local treated = obs

* Stockholm, high prox, T2
reg q28_w102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q28_w102 proximity_high if diraffected_sthlm==1, robust
est sto natid_diff_w10e2
estadd local treated = obs

reg security_sthlmw102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg security_sthlmw102 proximity_high if diraffected_sthlm==1, robust
est sto security_diff_w10e2
estadd local treated = obs

reg q24_1_w102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q24_1_w102 proximity_high if diraffected_sthlm==1, robust
est sto govtrust_diff_w10e2
estadd local treated = obs

reg q24_2_w102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg q24_2_w102 proximity_high if diraffected_sthlm==1, robust
est sto parltrust_diff_w10e2
estadd local treated = obs

reg fewerref102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg fewerref102 proximity_high if diraffected_sthlm==1, robust
est sto fewerref_diff_w10e2
estadd local treated = obs

reg muslimthreat102 if diraffected_sthlm==1 & proximity_high==1
scalar obs = e(N)
reg muslimthreat102 proximity_high if diraffected_sthlm==1, robust
est sto muslimthreat_diff_w10e2
estadd local treated = obs

set graphics off
coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Med/high proximity to attack", margin(medsmall) size(medlarge)) keep(proximity_medhigh) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l-0 r-0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(medhighprox2, replace)

coefplot (natid_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("High proximity to attack", margin(medsmall) size(medlarge)) keep(proximity_high) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l-0 r-0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(highprox2, replace)

set graphics on
gr combine medhighprox2 highprox2, col(2) scheme(s2mono) ysize(5) xsize(8) scale(1.1) title("Effect of personal proximity") 
* graph export  "`path'combined_proximity3_nomatch.pdf", replace

* TABLE 14 (online appendix), medhigh, T1
esttab natid_diff_w9e govtrust_diff_w9e parltrust_diff_w9e security_diff_w9e muslimthreat_diff_w9e fewerref_diff_w9e, se scalars("treated Treated ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("Med/high proximity: OLS estimates with restricted sample, T1") ///
label ///
tex compress b(a2) se(a2) width(16cm) keep(proximity_medhigh _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at T1. Sample is restricted to respondents who were in central Stockholm at the time of the attack. Treatment: Med/high proximity to attack. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
 * TABLE 15 (online appendix), medhigh, T2
esttab natid_diff_w10e govtrust_diff_w10e parltrust_diff_w10e security_diff_w10e muslimthreat_diff_w10e fewerref_diff_w10e, se scalars("treated Treated ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("Med/high proximity: OLS estimates with restricted sample, T2") ///
label ///
tex compress b(a2) se(a2) width(16cm) keep(proximity_medhigh _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at T2. Sample is restricted to respondents who were in central Stockholm at the time of the attack. Treatment: Med/high proximity to attack. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
 * TABLE 16 (online appendix), high, T1
esttab natid_diff_w9e2 govtrust_diff_w9e2 parltrust_diff_w9e2 security_diff_w9e2 muslimthreat_diff_w9e2 fewerref_diff_w9e2, se scalars("treated Treated ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("High proximity: OLS estimates with restricted sample, T1") ///
label ///
tex compress b(a2) se(a2) width(15.5cm) keep(proximity_high _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at T1. Sample is restricted to respondents who were in central Stockholm at the time of the attack. Treatment: Med/high proximity to attack. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
 * TABLE 17 (online appendix), high, T2
esttab natid_diff_w10e2 govtrust_diff_w10e2 parltrust_diff_w10e2 security_diff_w10e2 muslimthreat_diff_w10e2 fewerref_diff_w10e2, se scalars("treated Treated ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("High proximity: OLS estimates with restricted sample, T2") ///
label ///
tex compress b(a2) se(a2) width(15.5cm) keep(proximity_high _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at T2. Sample is restricted to respondents who were in central Stockholm at the time of the attack. Treatment: Med/high proximity to attack. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
 * Balance tests presented in online appendix (TABLE 13)
logit proximity_medhigh c.edu_resp i.bcountry2_resp i.sex_resp age sdvotew8 govvotew8 leftrightw8 i.stockholm_inhab i.large_muni if diraffected_sthlm==1
est sto bal_medhigh

logit proximity_high c.edu_resp i.bcountry2_resp i.sex_resp age sdvotew8 govvotew8 leftrightw8 i.stockholm_inhab i.large_muni if diraffected_sthlm==1
est sto bal_high

* TABLE 13 (online appendix)
esttab bal_medhigh bal_high, tex compress b(a2) se(a2) width(7cm) obslast scalars("p chi2") label ///
mti("Med/high prox." "High prox.") title("Balance test: Regression estimates with restricted sample, predicting med/high and high proximity") ///
coeflabels(edu_resp "Education" 2.bcountry2_resp "Foreign born" 2.sex_resp "Male" 3.sex_resp "Other" age "Age" sdvotew8 "SD-voter" govvotew8 "Gov.-voter" /// 
leftrightw8 "Left-right (1-10)" 1.stockholm_inhab "Stockholm inhab." 1.large_muni "Large muni. inhab.") ///
drop(0.stockholm_inhab 0.large_muni 1.sex_resp 1.bcountry2_resp) ///
addn(Note: Standard errors in parentheses. Logistic regression estimates. Predicting med/high and high proximity to attack, respectively. /// 
$\chi^2 < p$ is the p-value for a LR-test of joint significance of the coefficients. ///
Sample is restricted to respondents who were in central Stockholm at the time of the attack. ///
\newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes 

************************************************************************************************************************************************

// FIGURE 7: Long-term effects
// Proximity, matching
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg i.edu_resp leftrightw8 age 

* Stockholm, matching dir, w12
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (s1_q90_1_w122 = diraffected_sthlm q80_1_w82 $Creg), att
est sto govtrust_diff_w12e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (s1_q90_2_w122 = diraffected_sthlm q80_2_w82 $Creg), att
est sto parltrust_diff_w12e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlmw122 = diraffected_sthlm security_paris2 $Creg), att
est sto security_diff_w12e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (s1_q105_3_w122 = diraffected_sthlm fewercntrl_w92 $Creg), att
est sto fewerref_diff_w12e
estadd local adj "Yes"
matrix a = e(_N)
estadd local treated = a[1,1]
estadd local controls = a[1,4]

* Graph
set graphics on

coefplot /// 
(govtrust_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t3")) /// 
(parltrust_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t3"))  /// 
(fewerref_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer ref, t3")) /// 
(security_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t3")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("In central Stockholm", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+0 r+0 t+0 b+0)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4) swapnames name(insthlm, replace)

* TABLE 22 (online appendix), T3, proximity
esttab govtrust_diff_w12e parltrust_diff_w12e security_diff_w12e fewerref_diff_w12e, se scalars("adj Post-match adj." "treated Treated matched" "controls Controls used") obslast ///
mti("Gov trust" "Parl trust" "Security" "Refugees") title("In central Stockholm: Matching estimates, t3") ///
tex compress b(a2) se(a2) width(11.5cm) ///
addn(Note: Standard errors in parentheses. Outcomes measured at t3. Treatment: In central Stockholm during attack. /// 
Estimates based on coarsened exact matching. /// 
Matching variables include: education, foreign born, gender, age, SD-voter, /// 
government-voter, ideological placement on the left-right scale, past values of dependent variable, large municipality inhabitant, and Stockholm inhabitant. /// 
See appendix for coarsening details. Post-matching regression adjustment (OLS) with ///  
education (categorical dummies), age, left-right placement, and past values of dependent variable. \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes 

* General trends
reg govtrust_diff_w12 if wave8 == 1
est sto govtrust_diff_w12e

reg parltrust_diff_w12 if wave8 == 1
est sto parltrust_diff_w12e

reg security_diff_w12 if wave8 == 1
est sto security_diff_w12e

reg fewerref_diff_w12 if wave8 == 1 
est sto fewerref_diff_w12e

* Graph
set graphics on

coefplot /// 
(govtrust_diff_w12e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Gov trust, t3")) /// 
(parltrust_diff_w12e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Parl trust, t3"))  /// 
(fewerref_diff_w12e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Fewer ref, t3")) /// 
(security_diff_w12e, lc(black) mcolor(black) mstyle(p2) msize(small) ciop(lc(black)) aseq("Security, t3")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Difference between t3 and t0", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+1 r+1 t+0 b+0)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4) swapnames name(trends, replace)

* Stockholm, emotional response and attitudes
global Cw8 i.edu_resp i.bcountry2_resp i.sex_resp age agesq sdvotew8 govvotew8 leftrightw8 i.muni_resp // Controls Sthlm

gen Anger = anger_sthlm_01
gen Anxiety = anxiety_sthlm_01

reg security_sthlmw122 Anger Anxiety security_paris2 $Cw8, robust
est sto security_diff_w12e
estadd local controls "Yes"
estadd local fe "Yes"

reg s1_q90_1_w122 Anger Anxiety q80_1_w82 $Cw8, robust
est sto govtrust_diff_w12e
estadd local controls "Yes"
estadd local fe "Yes"

reg s1_q90_2_w122 Anger Anxiety q80_2_w82 $Cw8, robust
est sto parltrust_diff_w12e
estadd local controls "Yes"
estadd local fe "Yes"

reg s1_q105_3_w122 Anger Anxiety fewercntrl_w92 $Cw8, robust
est sto fewerref_diff_w12e
estadd local controls "Yes"
estadd local fe "Yes"

drop Anger Anxiety

* Emotional response, graph
coefplot /// 
(govtrust_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t3")) /// 
(parltrust_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t3"))  /// 
(fewerref_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer ref, t3")) /// 
(security_diff_w12e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t3")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Emotional response and attitudes", margin(medsmall) size(medlarge)) keep(Anger Anxiety)  /// 
xtitle("Coef. (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+0 r+0 t+0 b+0)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4) swapnames name(emo, replace)

* TABLE 21 (online appendix), T3, emotional
esttab govtrust_diff_w12e parltrust_diff_w12e security_diff_w12e fewerref_diff_w12e, se scalars("controls Controls " "fe Muni. FE ") obslast ///
mti("Gov trust" "Parl trust" "Security" "Refugees") title("Emotional response and attitudes: OLS estimates, t3") ///
label ///
tex compress b(a2) se(a2) width(11cm) keep(Anger Anxiety _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at t3. Emotions variables are normalized (min: 0, max: 1). Control variables include: /// 
education, foreign born, gender, age (including a squared term), SD-voter, /// 
government-voter, ideological placement on the left-right scale, and past values of dependent variable. Municipality fixed effects. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes

* Combine
set graphics on
gr combine trends emo insthlm, col(3) scheme(s2mono) ysize(5) xsize(11.8) title("Long-term effects", margin(medsmall) size(medlarge)) scale(1.1)
* graph export  "`path'longterm.pdf", replace


************************************************************************************************************************************************
****** ANALYSIS, APPENDIX + ONLINE APPENDIX ******
************************************************************************************************************************************************

// TABLE 5-7: Descriptives
tabstat edu_resp age leftrightw8 sdvotew8 govvotew8 stockholm_inhab large_muni bcountry2_resp sex_resp diraffected_sthlm proximity_medhigh proximity_high if wave9==1, ///
s(mean sd min max n) format(%10.3fc) c(statistics)

tabstat edu_resp age leftrightw8 sdvotew8 govvotew8 stockholm_inhab large_muni bcountry2_resp sex_resp diraffected_sthlm proximity_medhigh proximity_high if wave10==1, ///
s(mean sd min max n) format(%10.3fc) c(statistics)

tabstat s10_q85_w82 q28_w92 q28_w102 security_paris2 security_sthlm2 security_sthlmw102 security_sthlmw122 q80_1_w82 q24_1_w92 q24_1_w102 s1_q90_1_w122 q80_2_w82 q24_2_w92 q24_2_w102 s1_q90_2_w122 /// 
fewercntrl_w92 fewerref92 fewerref102 s1_q105_3_w122 muslimcntrl_w92 muslimthreat92 muslimthreat102 anger_sthlm_01 anxiety_sthlm_01, ///
s(mean sd min max n) format(%10.2fc) c(statistics)

************************************************************************************************************************************************

// FIGURE 8: emotional response and attitudes (online appendix)
global Cw8 i.edu_resp i.bcountry2_resp i.sex_resp age agesq sdvotew8 govvotew8 leftrightw8 i.muni_resp // Controls Sthlm

gen Anger = anger_sthlm_01
gen Anxiety = anxiety_sthlm_01

reg q28_w92 Anger Anxiety s10_q85_w82 $Cw8, robust
est sto natid_diff_w9e
estadd local controls "Yes"
estadd local fe "Yes"

reg security_sthlm2 Anger Anxiety security_paris2 $Cw8, robust
est sto security_diff_w9e
estadd local controls "Yes"
estadd local fe "Yes"

reg q24_1_w92 Anger Anxiety q80_1_w82 $Cw8, robust
est sto govtrust_diff_w9e
estadd local controls "Yes"
estadd local fe "Yes"

reg q24_2_w92 Anger Anxiety q80_2_w82 $Cw8, robust
est sto parltrust_diff_w9e
estadd local controls "Yes"
estadd local fe "Yes"

reg fewerref92 Anger Anxiety fewercntrl_w92 $Cw8, robust
est sto fewerref_diff_w9e
estadd local controls "Yes"
estadd local fe "Yes"

reg muslimthreat92 Anger Anxiety muslimcntrl_w92 $Cw8, robust
est sto muslimthreat_diff_w9e
estadd local controls "Yes"
estadd local fe "Yes"

reg q28_w102 Anger Anxiety s10_q85_w82 $Cw8, robust
est sto natid_diff_w10e
estadd local controls "Yes"
estadd local fe "Yes"

reg security_sthlmw102 Anger Anxiety security_paris2 $Cw8, robust
est sto security_diff_w10e
estadd local controls "Yes"
estadd local fe "Yes"

reg q24_1_w102 Anger Anxiety q80_1_w82 $Cw8, robust
est sto govtrust_diff_w10e
estadd local controls "Yes"
estadd local fe "Yes"

reg q24_2_w102 Anger Anxiety q80_2_w82 $Cw8, robust
est sto parltrust_diff_w10e
estadd local controls "Yes"
estadd local fe "Yes"

reg fewerref102 Anger Anxiety fewercntrl_w92 $Cw8, robust
est sto fewerref_diff_w10e
estadd local controls "Yes"
estadd local fe "Yes"

reg muslimthreat102 Anger Anxiety muslimcntrl_w92 $Cw8, robust
est sto muslimthreat_diff_w10e
estadd local controls "Yes"
estadd local fe "Yes"

drop Anger Anxiety

* Emotional response, graph
* Rally effects
set graphics off
coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) ///
(natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov. trust, t1")) /// 
(govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov. trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl. trust, t1")) ///
(parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl. trust, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) keep(Anger Anxiety)  /// 
xtitle("Coef. (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+0 r+0 t+0 b+0)) ///
xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(sthlmrally, replace)

* Threat/security/immigrants
set graphics off
coefplot ///
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) /// 
(muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) /// 
(fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) ///
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) /// 
(security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) keep(Anger Anxiety)  /// 
xtitle("Coef. (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+0 r+0 t+0 b+0)) ///
xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(sthlmsec, replace)

set graphics on
gr combine sthlmrally sthlmsec, col(3) scheme(s2mono) ysize(5) xsize(8) title("Emotional response and attitudes", margin(medsmall) size(medlarge)) scale(1.1)
* graph export  "`path'emotional_response2.pdf", replace

* TABLE 9, T1
esttab natid_diff_w9e govtrust_diff_w9e parltrust_diff_w9e security_diff_w9e muslimthreat_diff_w9e fewerref_diff_w9e, se scalars("controls Controls " "fe Muni. FE ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("Emotional response and attitudes: OLS estimates, t1") ///
label ///
tex compress b(a2) se(a2) width(14.5cm) keep(Anger Anxiety _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at t1. Emotions variables are normalized (min: 0, max: 1). Control variables include: /// 
education, foreign born, gender, age (including a squared term), SD-voter, /// 
government-voter, ideological placement on the left-right scale, and past values of dependent variable. Municipality fixed effects. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
 * TABLE 10, T2
esttab natid_diff_w10e govtrust_diff_w10e parltrust_diff_w10e security_diff_w10e muslimthreat_diff_w10e fewerref_diff_w10e, se scalars("controls Controls " "fe Muni. FE ") obslast ///
mti("Nat id" "Gov trust" "Parl trust" "Security" "Muslims" "Refugees") title("Emotional response and attitudes: OLS estimates, t2") ///
label ///
tex compress b(a2) se(a2) width(14.5cm) keep(Anger Anxiety _cons) ar2 ///
addn(Note: Robust standard errors in parentheses. OLS estimates with outcomes measured at t2. Emotions variables are normalized (min: 0, max: 1). Control variables include: /// 
education, foreign born, gender, age (including a squared term), SD-voter, /// 
government-voter, ideological placement on the left-right scale, and past values of dependent variable. Municipality fixed effects. /// 
 \newline $^{*}$ p $<$ 0.05; $^{**}$ p $<$ 0.01; $^{***}$ p $<$ 0.001.) nonotes
 
************************************************************************************************************************************************

// FIGURE 9 + FIGURE 10: Emotional response, proximity - matching
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 

* Affected proximity
kmatch em proximity_medhigh $Cw82 (q16_w92 = proximity_medhigh $Creg2 ) if diraffected_sthlm==1, att
est sto medhighproxe
kmatch em proximity_medhigh $Cw82 (q16_w92 = proximity_medhigh $Creg2 ), att
est sto medhighproxalle
kmatch em proximity_high $Cw82 (q16_w92 = proximity_high $Creg2 ) if diraffected_sthlm==1, att
est sto highproxe
kmatch em proximity_high $Cw82 (q16_w92 = proximity_high $Creg2 ), att
est sto highproxalle
kmatch em proximity_medhigh $Cw82 (q16_w102 = proximity_medhigh $Creg2 ) if diraffected_sthlm==1, att
est sto medhighproxe10
kmatch em proximity_medhigh $Cw82 (q16_w102 = proximity_medhigh $Creg2 ), att
est sto medhighproxalle10
kmatch em proximity_high $Cw82 (q16_w102 = proximity_high $Creg2 ) if diraffected_sthlm==1, att
est sto highproxe10
kmatch em proximity_high $Cw82 (q16_w102 = proximity_high $Creg2 ), att
est sto highproxalle10

* Anger proximity
kmatch em proximity_medhigh $Cw82 (anger_sthlm_01 = proximity_medhigh $Creg2 ) if diraffected_sthlm==1, att
est sto medhighproxe2
kmatch em proximity_medhigh $Cw82 (anger_sthlm_01 = proximity_medhigh $Creg2 ), att
est sto medhighproxalle2
kmatch em proximity_high $Cw82 (anger_sthlm_01 = proximity_high $Creg2 ) if diraffected_sthlm==1, att
est sto highproxe2
kmatch em proximity_high $Cw82 (anger_sthlm_01 = proximity_high $Creg2 ), att
est sto highproxalle2
kmatch em proximity_medhigh $Cw82 (anger_sthlm_01w10 = proximity_medhigh $Creg2 ) if diraffected_sthlm==1, att
est sto medhighproxe102
kmatch em proximity_medhigh $Cw82 (anger_sthlm_01w10 = proximity_medhigh $Creg2 ), att
est sto medhighproxalle102
kmatch em proximity_high $Cw82 (anger_sthlm_01w10 = proximity_high $Creg2 ) if diraffected_sthlm==1, att
est sto highproxe102
kmatch em proximity_high $Cw82 (anger_sthlm_01w10 = proximity_high $Creg2 ), att
est sto highproxalle102

* Anxiety proximity
kmatch em proximity_medhigh $Cw82 (anxiety_sthlm_01 = proximity_medhigh $Creg2 ) if diraffected_sthlm==1, att
est sto medhighproxe3
kmatch em proximity_medhigh $Cw82 (anxiety_sthlm_01 = proximity_medhigh $Creg2 ), att
est sto medhighproxalle3
kmatch em proximity_high $Cw82 (anxiety_sthlm_01 = proximity_high $Creg2 ) if diraffected_sthlm==1, att
est sto highproxe3
kmatch em proximity_high $Cw82  (anxiety_sthlm_01 = proximity_high $Creg2 ), att
est sto highproxalle3
kmatch em proximity_medhigh $Cw82 (anxiety_sthlm_01w10 = proximity_medhigh $Creg2 ) if diraffected_sthlm==1, att
est sto medhighproxe103
kmatch em proximity_medhigh $Cw82 (anxiety_sthlm_01w10 = proximity_medhigh $Creg2 ), att
est sto medhighproxalle103
kmatch em proximity_high $Cw82 (anxiety_sthlm_01w10 = proximity_high $Creg2 ) if diraffected_sthlm==1, att
est sto highproxe103
kmatch em proximity_high $Cw82  (anxiety_sthlm_01w10 = proximity_high $Creg2 ), att
est sto highproxalle103

set graphics off
coefplot (medhighproxe, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxe10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxe, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxe10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Subjectively affected by attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(affected, replace)

coefplot (medhighproxe2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxe102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxe2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxe102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Feeling anger", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(anger, replace)

coefplot (medhighproxe3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxe103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxe3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxe103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Feeling anxiety", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(anxiety, replace)

set graphics on
gr combine affected anger anxiety, col(3) scheme(s2mono) ysize(5) xsize(13) scale(1.1) title("Effect of personal proximity, matching (restricted sample)") 
graph export  "`path'combined_proximity4_matching.pdf", replace

set graphics off
coefplot (medhighproxalle, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxalle10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxalle, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxalle10, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Subjectively affected by attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(affected, replace)

coefplot (medhighproxalle2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxalle102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxalle2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxalle102, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Feeling anger", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(anger, replace)

coefplot (medhighproxalle3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T1")) (medhighproxalle103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Med/high prox, T2")) /// 
(highproxalle3, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T1")) (highproxalle103, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("High prox, T2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Feeling anxiety", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(anxiety, replace)

set graphics on
gr combine affected anger anxiety, col(3) scheme(s2mono) ysize(5) xsize(13) scale(1.1) title("Effect of personal proximity, matching (full sample)") 
* graph export  "`path'combined_proximity4_matchingall.pdf", replace

************************************************************************************************************************************************

// FIGURE 11: Matching, Sthlm medhigh/high proximity - between-group diff - restricted sample
global Cw83 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 

* Stockholm, matching medhigh prox
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w92 = proximity_medhigh s10_q85_w82 $Creg2) if diraffected_sthlm==1, att
est sto natid_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlm2 = proximity_medhigh security_paris2 $Creg2) if diraffected_sthlm==1, att
est sto security_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w92 = proximity_medhigh q80_1_w82 $Creg2) if diraffected_sthlm==1, att
est sto govtrust_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w92 = proximity_medhigh q80_2_w82 $Creg2) if diraffected_sthlm==1, att
est sto parltrust_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref92 = proximity_medhigh fewercntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto fewerref_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat92 = proximity_medhigh muslimcntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto muslimthreat_diff_w9e

kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w102 = proximity_medhigh s10_q85_w82 $Creg2) if diraffected_sthlm==1, att
est sto natid_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlmw102 = proximity_medhigh security_paris2 $Creg2) if diraffected_sthlm==1, att
est sto security_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w102 = proximity_medhigh q80_1_w82 $Creg2) if diraffected_sthlm==1, att
est sto govtrust_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w102 = proximity_medhigh q80_2_w82 $Creg2) if diraffected_sthlm==1, att
est sto parltrust_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref102 = proximity_medhigh fewercntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto fewerref_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat102 = proximity_medhigh muslimcntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto muslimthreat_diff_w10e

* Stockholm, matching high prox
kmatch em proximity_high (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w92 = proximity_high s10_q85_w82 $Creg2) if diraffected_sthlm==1, att
est sto natid_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlm2 = proximity_high security_paris2 $Creg2) if diraffected_sthlm==1, att
est sto security_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w92 = proximity_high q80_1_w82 $Creg2) if diraffected_sthlm==1, att
est sto govtrust_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w92 = proximity_high q80_2_w82 $Creg2) if diraffected_sthlm==1, att
est sto parltrust_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref92 = proximity_high fewercntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto fewerref_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat92 = proximity_high muslimcntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto muslimthreat_diff_w9e2

kmatch em proximity_high (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w102 = proximity_high s10_q85_w82 $Creg2) if diraffected_sthlm==1, att
est sto natid_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlmw102 = proximity_high security_paris2 $Creg2) if diraffected_sthlm==1, att
est sto security_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w102 = proximity_high q80_1_w82 $Creg2) if diraffected_sthlm==1, att
est sto govtrust_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w102 = proximity_high q80_2_w82 $Creg2) if diraffected_sthlm==1, att
est sto parltrust_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref102 = proximity_high fewercntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto fewerref_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat102 = proximity_high muslimcntrl_w92 $Creg2) if diraffected_sthlm==1, att
est sto muslimthreat_diff_w10e2

set graphics off
coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Med/high proximity to attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(medhighprox2, replace)

coefplot (natid_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("High proximity to attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(highprox2, replace)

set graphics on
gr combine medhighprox2 highprox2, col(2) scheme(s2mono) ysize(5) xsize(8) scale(1.1) title("Effect of personal proximity, matching (restricted sample)") 
* graph export  "`path'combined_proximity3.pdf", replace

************************************************************************************************************************************************

* FIGURE 12: Matching, Sthlm medhigh/high proximity - between-group diff - matching against complete sample
global Cw83 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 

* Stockholm, matching medhigh prox
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w92 = proximity_medhigh s10_q85_w82 $Creg2), att
est sto natid_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlm2 = proximity_medhigh security_paris2 $Creg2), att
est sto security_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w92 = proximity_medhigh q80_1_w82 $Creg2), att
est sto govtrust_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w92 = proximity_medhigh q80_2_w82 $Creg2), att
est sto parltrust_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref92 = proximity_medhigh fewercntrl_w92 $Creg2), att
est sto fewerref_diff_w9e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat92 = proximity_medhigh muslimcntrl_w92 $Creg2), att
est sto muslimthreat_diff_w9e

kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w102 = proximity_medhigh s10_q85_w82 $Creg2), att
est sto natid_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlmw102 = proximity_medhigh security_paris2 $Creg2), att
est sto security_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w102 = proximity_medhigh q80_1_w82 $Creg2), att
est sto govtrust_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w102 = proximity_medhigh q80_2_w82 $Creg2), att
est sto parltrust_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref102 = proximity_medhigh fewercntrl_w92 $Creg2), att
est sto fewerref_diff_w10e
kmatch em proximity_medhigh (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat102 = proximity_medhigh muslimcntrl_w92 $Creg2), att
est sto muslimthreat_diff_w10e

* Stockholm, matching high prox
kmatch em proximity_high (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w92 = proximity_high s10_q85_w82 $Creg2), att
est sto natid_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlm2 = proximity_high security_paris2 $Creg2), att
est sto security_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w92 = proximity_high q80_1_w82 $Creg2), att
est sto govtrust_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w92 = proximity_high q80_2_w82 $Creg2), att
est sto parltrust_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref92 = proximity_high fewercntrl_w92 $Creg2), att
est sto fewerref_diff_w9e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat92 = proximity_high muslimcntrl_w92 $Creg2), att
est sto muslimthreat_diff_w9e2

kmatch em proximity_high (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw83 (q28_w102 = proximity_high s10_q85_w82 $Creg2), att
est sto natid_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) security_paris2 $Cw83 (security_sthlmw102 = proximity_high security_paris2 $Creg2), att
est sto security_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_1_w82 $Cw83 (q24_1_w102 = proximity_high q80_1_w82 $Creg2), att
est sto govtrust_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) q80_2_w82 $Cw83 (q24_2_w102 = proximity_high q80_2_w82 $Creg2), att
est sto parltrust_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw83 (fewerref102 = proximity_high fewercntrl_w92 $Creg2), att
est sto fewerref_diff_w10e2
kmatch em proximity_high (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw83 (muslimthreat102 = proximity_high muslimcntrl_w92 $Creg2), att
est sto muslimthreat_diff_w10e2

set graphics off
coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Med/high proximity to attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(medhighprox2, replace)

coefplot (natid_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e2, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e2, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("High proximity to attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.5) swapnames name(highprox2, replace)

set graphics on
gr combine medhighprox2 highprox2, col(2) scheme(s2mono) ysize(5) xsize(8) scale(1.1) title("Effect of personal proximity, matching (complete sample)") 
* graph export  "`path'combined_proximity3_samplematch.pdf", replace

************************************************************************************************************************************************

// FIGURE 13: Proximity, matching, restrict to w8
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 

* Stockholm, matching dir
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w92 = diraffected_sthlm s10_q85_w82 $Creg2) if wave8==1, att
est sto natid_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlm2 = diraffected_sthlm security_paris2 $Creg2) if wave8==1, att
est sto security_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w92 = diraffected_sthlm q80_1_w82 $Creg2) if wave8==1, att
est sto govtrust_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w92 = diraffected_sthlm q80_2_w82 $Creg2) if wave8==1, att
est sto parltrust_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref92 = diraffected_sthlm fewercntrl_w92 $Creg2) if wave8==1, att
est sto fewerref_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat92 = diraffected_sthlm muslimcntrl_w92 $Creg2) if wave8==1, att
est sto muslimthreat_diff_w9e

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w102 = diraffected_sthlm s10_q85_w82 $Creg2) if wave8==1, att
est sto natid_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlmw102 = diraffected_sthlm security_paris2 $Creg2) if wave8==1, att
est sto security_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w102 = diraffected_sthlm q80_1_w82 $Creg2) if wave8==1, att
est sto govtrust_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w102 = diraffected_sthlm q80_2_w82 $Creg2) if wave8==1, att
est sto parltrust_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref102 = diraffected_sthlm fewercntrl_w92 $Creg2) if wave8==1, att
est sto fewerref_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat102 = diraffected_sthlm muslimcntrl_w92 $Creg2) if wave8==1, att
est sto muslimthreat_diff_w10e

set graphics on

coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("In central Stockholm during attack (w8)", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.3) swapnames name(insthlm, replace)
* graph export  "`path'combined_proximity1_appendix.pdf", replace

************************************************************************************************************************************************

// FIGURE 14: Proximity, matching, propensity
global Cw82 edu_resp age leftrightw8 bcountry2_resp sex_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 

* Stockholm, matching dir
kmatch ps diraffected_sthlm s10_q85_w82 $Cw82 (q28_w92 = diraffected_sthlm), att
est sto natid_diff_w9e
kmatch ps diraffected_sthlm security_paris2 $Cw82 (security_sthlm2 = diraffected_sthlm), att
est sto security_diff_w9e
kmatch ps diraffected_sthlm q80_1_w82 $Cw82 (q24_1_w92 = diraffected_sthlm), att
est sto govtrust_diff_w9e
kmatch ps diraffected_sthlm q80_2_w82 $Cw82 (q24_2_w92 = diraffected_sthlm), att
est sto parltrust_diff_w9e
kmatch ps diraffected_sthlm fewercntrl_w92 $Cw82 (fewerref92 = diraffected_sthlm), att
est sto fewerref_diff_w9e
kmatch ps diraffected_sthlm muslimcntrl_w92 $Cw82 (muslimthreat92 = diraffected_sthlm), att
est sto muslimthreat_diff_w9e

kmatch ps diraffected_sthlm s10_q85_w82 $Cw82 (q28_w102 = diraffected_sthlm), att
est sto natid_diff_w10e
kmatch ps diraffected_sthlm security_paris2 $Cw82 (security_sthlmw102 = diraffected_sthlm), att
est sto security_diff_w10e
kmatch ps diraffected_sthlm q80_1_w82 $Cw82 (q24_1_w102 = diraffected_sthlm), att
est sto govtrust_diff_w10e
kmatch ps diraffected_sthlm q80_2_w82 $Cw82 (q24_2_w102 = diraffected_sthlm), att
est sto parltrust_diff_w10e
kmatch ps diraffected_sthlm fewercntrl_w92 $Cw82 (fewerref102 = diraffected_sthlm), att
est sto fewerref_diff_w10e
kmatch ps diraffected_sthlm muslimcntrl_w92 $Cw82 (muslimthreat102 = diraffected_sthlm), att
est sto muslimthreat_diff_w10e

set graphics on

coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("In central Stockholm during attack (PS)", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.3) swapnames name(insthlm, replace)
* graph export  "`path'combined_proximity1_appendixPS.pdf", replace

************************************************************************************************************************************************

// FIGURE 15: Proximity, matching, restrict to first wave of wave 9
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 

* Stockholm, matching dir
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w92 = diraffected_sthlm s10_q85_w82 $Creg2) if w9_wave==1, att
est sto natid_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlm2 = diraffected_sthlm security_paris2 $Creg2) if w9_wave==1, att
est sto security_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w92 = diraffected_sthlm q80_1_w82 $Creg2) if w9_wave==1, att
est sto govtrust_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w92 = diraffected_sthlm q80_2_w82 $Creg2) if w9_wave==1, att
est sto parltrust_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref92 = diraffected_sthlm fewercntrl_w92 $Creg2) if w9_wave==1, att
est sto fewerref_diff_w9e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat92 = diraffected_sthlm muslimcntrl_w92 $Creg2) if w9_wave==1, att
est sto muslimthreat_diff_w9e

kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w102 = diraffected_sthlm s10_q85_w82 $Creg2) if w9_wave==1, att
est sto natid_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlmw102 = diraffected_sthlm security_paris2 $Creg2) if w9_wave==1, att
est sto security_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w102 = diraffected_sthlm q80_1_w82 $Creg2) if w9_wave==1, att
est sto govtrust_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w102 = diraffected_sthlm q80_2_w82 $Creg2) if w9_wave==1, att
est sto parltrust_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref102 = diraffected_sthlm fewercntrl_w92 $Creg2) if w9_wave==1, att
est sto fewerref_diff_w10e
kmatch em diraffected_sthlm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat102 = diraffected_sthlm muslimcntrl_w92 $Creg2) if w9_wave==1, att
est sto muslimthreat_diff_w10e

set graphics on

coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1"))  /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1"))  /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1"))  /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1"))  /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1"))  /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("In central Stockholm, only first wave of w9", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) graphregion(margin(l+0 r+1 t+0 b+0)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.3) swapnames name(insthlm, replace)
* graph export  "`path'combined_proximityfirst_appendix.pdf", replace

************************************************************************************************************************************************

// FIGURE 16: Proximity, matching, respondents in Stockholm+living in Stockholm
global Cw82 (4.5 6.5) edu_resp (29.5 39.5 49.5 64.5) age (2.5 4.5 5.5 7.5) leftrightw8 (1.5 2.5) sex_resp (asis) bcountry2_resp sdvotew8 govvotew8 stockholm_inhab large_muni // Match Sthlm
global Creg2 i.edu_resp leftrightw8 age 
gen treated_stockholm = diraffected_sthlm*stockholm_inhab

* Stockholm, matching dir
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w92 = treated_stockholm s10_q85_w82 $Creg2), att
est sto natid_diff_w9e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlm2 = treated_stockholm security_paris2 $Creg2), att
est sto security_diff_w9e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w92 = treated_stockholm q80_1_w82 $Creg2), att
est sto govtrust_diff_w9e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w92 = treated_stockholm q80_2_w82 $Creg2), att
est sto parltrust_diff_w9e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref92 = treated_stockholm fewercntrl_w92 $Creg2), att
est sto fewerref_diff_w9e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat92 = treated_stockholm muslimcntrl_w92 $Creg2), att
est sto muslimthreat_diff_w9e

kmatch em treated_stockholm (0.17 0.35 0.55 0.68) s10_q85_w82 $Cw82 (q28_w102 = treated_stockholm s10_q85_w82 $Creg2), att
est sto natid_diff_w10e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) security_paris2 $Cw82 (security_sthlmw102 = treated_stockholm security_paris2 $Creg2), att
est sto security_diff_w10e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) q80_1_w82 $Cw82 (q24_1_w102 = treated_stockholm q80_1_w82 $Creg2), att
est sto govtrust_diff_w10e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) q80_2_w82 $Cw82 (q24_2_w102 = treated_stockholm q80_2_w82 $Creg2), att
est sto parltrust_diff_w10e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) fewercntrl_w92 $Cw82 (fewerref102 = treated_stockholm fewercntrl_w92 $Creg2), att
est sto fewerref_diff_w10e
kmatch em treated_stockholm (0.17 0.35 0.55 0.68) muslimcntrl_w92 $Cw82 (muslimthreat102 = treated_stockholm muslimcntrl_w92 $Creg2), att
est sto muslimthreat_diff_w10e

set graphics on

coefplot (natid_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("National id, t1")) (natid_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("National id, t2")) /// 
(govtrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Gov trust, t1")) (govtrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Gov trust, t2")) /// 
(parltrust_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Parl trust, t1")) (parltrust_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Parl trust, t2")) /// 
(muslimthreat_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Muslims threat, t1")) (muslimthreat_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Muslims threat, t2")) /// 
(fewerref_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Fewer refugees, t1")) (fewerref_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Fewer refugees, t2")) /// 
(security_diff_w9e, lc(black) mcolor(black) mstyle(p2) ciop(lc(black)) aseq("Security, t1")) (security_diff_w10e, lc(gs5) mcolor(gs5) msize(medlarge) msymbol(S) ciop(lc(gs5)) aseq("Security, t2")), /// 
xline(0, lp(dash) lc(gs8)) scheme(s2mono) legend(off) title("Living in Stockholm and" "in central Stockholm during attack", margin(medsmall) size(medlarge)) /// 
xtitle("Effect (outcome range: 0 - 1)", margin(medsmall)) plotregion(margin(l+0 r+0 t+1 b+1)) xscale(r(-0.15 0.15)) xlabel(-0.15 -0.1 -0.05 0 0.05 0.1 0.15) ysize(4) xsize(4.3) swapnames name(insthlm, replace)
* graph export  "`path'livinginsthlm.pdf", replace